home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-03 / iqb9107.zip / INSRTDSK.BAS < prev    next >
BASIC Source File  |  1991-05-24  |  2KB  |  61 lines

  1. ' InsrtDsk.Bas
  2. ' $INCLUDE: 'QB.BI'
  3. CONST FALSE = 0, TRUE = NOT FALSE
  4.  
  5. DIM Regs AS RegTypeX
  6. DIM AH AS INTEGER
  7. ' Although the Verify Sector operation transfers no disk data,
  8. ' the specifications require a valid transfer buffer equal in
  9. ' size to the number of sectors times the sector size. Since
  10. ' virtually all diskettes use a sector size of 512 bytes, and
  11. ' we are just verifying one sector, we need a buffer of 256.
  12. DIM DummyBuffer(256)  AS INTEGER
  13.  
  14. Tries% = 1          ' counter for number of Verify attempts
  15. Done% = FALSE       ' flag to control Verify attempt loop
  16. Drive% = 0          ' 0=drive A, 1=drive B, etc.
  17. NSectors% = 1       ' number of sectors to verify
  18. Cylinder% = 0       ' disk cylinder number
  19. Sector% = 1         ' disk sector number
  20. Head% = 0           ' disk head number
  21. ' Make a string version of the drive to use in PRINT statements
  22. DriveLetter$ = CHR$(ASC("A") + Drive%)
  23. ' Prompt the user to insert a diskette in the drive
  24. PRINT "Please place a formatted floppy disk in drive ";
  25. PRINT DriveLetter$; "..."
  26. DO
  27.   ' Set up the input parameters for the Verify Sector operation
  28.   Regs.AX = &H4 * 256 OR NSectors%
  29.   Regs.CX = Cylinder% * 256 OR Sector%
  30.   Regs.DX = Head% * 256 OR Drive%
  31.   Regs.ES = VARSEG(DummyBuffer(0))
  32.   Regs.BX = VARPTR(DummyBuffer(0))
  33.   ' Issue the Low-level DIsk I/O interrupt
  34.   InterruptX &H13, Regs, Regs
  35.   ' Check for an error status
  36.   IF Regs.flags AND 1 THEN
  37.     AH = (Regs.AX \ 256) AND &HFF
  38.     'PRINT "Error status is "; HEX$(AH)
  39.     Tries% = Tries% + 1
  40.     ' Reset the drive, in case the motor was off...
  41.     Regs.AX = 0
  42.     Regs.DX = Drive%
  43.     InterruptX &H13, Regs, Regs
  44.   ELSE
  45.     AH = 0        ' clear any previous error
  46.     Done% = TRUE  ' yes, we're done!
  47.   END IF
  48. LOOP UNTIL Done% OR Tries% > 3
  49. ' Now interpret the result
  50. IF AH <> 0 THEN
  51.   PRINT "Cannot read drive ";
  52.   PRINT DriveLetter$;
  53.   PRINT ", status is "; HEX$(AH)
  54. ELSE
  55.   PRINT "There is a formatted disk in drive ";
  56.   PRINT DriveLetter$
  57.   PRINT "It took "; Tries%; " tries to get the disk spun-up."
  58. END IF
  59. END
  60.  
  61.